package com.spring.demo.core.job;

import java.util.Date;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.spring.demo.core.service.IMailService;
import com.spring.demo.util.DateUtil;

@QuartzJob(name="SendEmailJob", cronExp="0 0/1 * * * ?")
public class SendEmailJob extends QuartzJobBean {

	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private IMailService mailService;

	public void setMailService(IMailService mailService) {
		this.mailService = mailService;
	}

	@Override
	protected void executeInternal(JobExecutionContext context)
			throws JobExecutionException {
		Date now = DateUtil.now();
		logger.debug(now.toString());
		mailService.sendAlertMail("定时任务测试: " + now);

	}

}
